using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CodePlex.SpaceBlock;
using CodePlex.Resourceful;
using System.Diagnostics;

namespace CodePlex.SpaceBlock.UI.Controls.Tools
{
    public partial class NirvanixSettingsControl : BaseControl
    {

        public NirvanixSettingsControl()
        {
            InitializeComponent();

            _noteBox.Text = Properties.Messages.Options_Nirvanix_SSL_Note;

            _lookupLink.Text = Properties.Messages.Options_Nirvanix_NirvanixLookup;
            _createLink.Text = Properties.Messages.Options_Nirvanix_NirvanixSignup;


            _useSSLCheck.CheckedChanged += delegate
            {
                this.UpdateData();
            };
          
        }

        public void Initialize(FileSystemInfo info)
        {

            UIUtils.Bind(_appKeyBox, info.PublicSettings, UIConstants.NirvanixSettings.AppKey);
            UIUtils.Bind(_appNameBox, info.PublicSettings, UIConstants.NirvanixSettings.AppName);
            UIUtils.Bind(_usernameBox, info.PublicSettings, UIConstants.NirvanixSettings.Username);
            UIUtils.Bind(_passwordBox, info.PrivateSettings, UIConstants.NirvanixSettings.Password);
            UIUtils.Bind(_useSSLCheck, info.PublicSettings, UIConstants.NirvanixSettings.UseSSL);

           this.UpdateData();
        }


        private void UpdateData()
        {
            _noteBox.Visible = !_useSSLCheck.Checked;
            _noteLink.Visible = !_useSSLCheck.Checked;
        }

        private void _noteLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Process.Start(Properties.Messages.Urls_Nirvanix_SSLWarning);
        }

        private void _lookupLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Process.Start(Properties.Messages.Urls_Nirvanix_Lookup);
        }

        private void _createLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Process.Start(Properties.Messages.Urls_Nirvanix_Signup);
        }


       
    }
}

